﻿package view.mainUI
{
    import __AS3__.vec.*;
    import com.greensock.*;
    import com.sh.game.util.*;
    import flash.display.*;
    import flash.text.*;
    import morn.core.components.*;

    public class LogUI extends Sprite
    {
        private var mPanel:Panel;
        private var mTxtList:Vector.<Label>;
        private var mFormat:TextFormat;

        public function LogUI()
        {
            mouseEnabled = false;
            mouseChildren = false;
            this.mTxtList = new Vector.<Label>;
            this.mPanel = new Panel();
            this.mPanel.width = 200;
            this.mPanel.height = 125;
            addChild(this.mPanel);
            this.mFormat = new TextFormat();
            this.mFormat.font = "宋体";
            return;
        }// end function

        public function addLog(param1:String, param2:String = "FE0000") : void
        {
            var _loc_3:Label = null;
            if (!param1)
            {
                return;
            }
            _loc_3 = new Label();
            _loc_3.width = 180;
            _loc_3.stroke = "0x0";
            _loc_3.align = "left";
            _loc_3.isHtml = true;
            if (param1.indexOf("获得") == 0)
            {
                if (param1.search("内功经验") > -1)
                {
                    _loc_3.color = MColor.New54;
                }
                else
                {
                    _loc_3.color = MColor.New54;
                }
            }
            else if (param1.indexOf("失去") == 0)
            {
                _loc_3.color = MColor.New54;
            }
            else
            {
                _loc_3.color = MColor.New54;
            }
            _loc_3.text = param1;
            _loc_3.y = this.mTxtList.length * 18;
            this.mPanel.addChild(_loc_3);
            this.mTxtList.push(_loc_3);
            TweenLite.to(_loc_3, 7, {delay:3, alpha:0.2, onComplete:this.completeHandler, onCompleteParams:[_loc_3]});
            return;
        }// end function

        public function addNewLog(param1:Object) : void
        {
            var _loc_4:String = null;
            var _loc_2:* = new Label();
            _loc_2.width = 180;
            _loc_2.stroke = "0x0";
            _loc_2.align = "left";
            _loc_2.isHtml = true;
            var _loc_3:String = "";
            if (param1.type == 1)
            {
                if (param1.itemid >= 100)
                {
                    _loc_2.color = MColor.New54;
                    _loc_4 = MColor.getqualitycolor(param1.quality);
                    _loc_3 = "获得 <font color=\'" + _loc_4 + "\' >" + param1.name + "*" + param1.count + "</font>";
                }
                else if (param1.itemid <= 3)
                {
                    _loc_2.color = MColor.New54;
                    _loc_3 = "获得 " + param1.count + " " + param1.name;
                }
                else
                {
                    _loc_2.color = MColor.New54;
                    _loc_3 = "获得 " + param1.count + " " + param1.name;
                }
            }
            else
            {
                _loc_2.color = MColor.New54;
                if (param1.itemid >= 100)
                {
                    _loc_4 = MColor.getqualitycolor(param1.quality);
                    _loc_3 = "失去 <font color=\'" + _loc_4 + "\' >" + param1.name + "*" + param1.count + "</font>";
                }
                else
                {
                    _loc_3 = "失去 " + param1.count + " " + param1.name;
                }
            }
            _loc_2.stroke = "0x0";
            _loc_2.align = "left";
            _loc_2.isHtml = true;
            _loc_2.text = _loc_3;
            _loc_2.y = this.mTxtList.length * 18;
            this.mPanel.addChild(_loc_2);
            this.mTxtList.push(_loc_2);
            TweenLite.to(_loc_2, 7, {delay:3, alpha:0.2, onComplete:this.completeHandler, onCompleteParams:[_loc_2]});
            return;
        }// end function

        private function completeHandler(param1:Label) : void
        {
            var _loc_2:* = this.mTxtList.indexOf(param1);
            if (_loc_2 > -1)
            {
                this.mTxtList.splice(_loc_2, 1);
            }
            if (param1.parent)
            {
                param1.parent.removeChild(param1);
            }
            param1 = null;
            var _loc_3:int = 0;
            var _loc_4:* = this.mTxtList.length;
            _loc_3 = 0;
            while (_loc_3 < _loc_4)
            {
                
                this.mTxtList[_loc_3].y = _loc_3 * 18;
                _loc_3++;
            }
            return;
        }// end function

    }
}
